package org.grayrabbit.cloud.core.biz;

import org.apache.commons.lang.StringUtils;
import org.grayrabbit.cloud.core.config.ConfiguratorException;
import org.grayrabbit.cloud.core.module.Module;
import org.grayrabbit.cloud.core.module.ServerModule;
import org.grayrabbit.cloud.core.rpc.Argument;
import org.grayrabbit.cloud.core.rpc.Result;
import org.grayrabbit.cloud.core.rpc.ServerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public abstract class BizServerModule extends
		ServerModule<Result, Argument> implements
		Module<Result, Argument> {
	private static final Logger logger = LoggerFactory.getLogger(BizServerModule.class);
	protected int getServerPort() {
		try {
			String port = ServerUtility.getProperty("module", this.name, "port");
			if(StringUtils.isNotBlank(port)){
				return Integer.parseInt(port);
			}
		} catch (ConfiguratorException e) {
			logger.error("获取服务器端口异常：",e);
		}
		return 0;
	}

	protected ServerFactory getServerFactory() {
		return BizUtility.getServerFactory();
	}
}
